package com.weiyi.servlet03;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.Part;


/**
 * 
 * @description 使用part方式上传文件2
 * @author 惟一
 * @date 2020年6月26日下午5:54:56
 */
@MultipartConfig(location = "F://")
@WebServlet("/upload2.do")
public class UploadDemo2 extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");//为了处理中文乱码
		Part part = req.getPart("photo");
		String filename = getFilename(part);
		part.write(filename);//将文件写入location指定目录
	}

	private String getFilename(Part part) {
		return null;
	}
}
